//查看新闻正文
getNewsContent =function(url){
	var left = (window.screen.width-900)/2;
	var top = (window.screen.height-500)/2;
	window.open(url,"_blank","toolbar=no,titlebar=no,resizable=yes,scrollbars=yes,width=1000px,height=620,top="+top+",left="+left);
}

/**更多 */
getNewsTitles =function(url){
	window.open(url,"_blank");
}

function addeditor($textarea) {
	var allPlugin={
		createAnchor:{c:'createAnchor',t:'创建锚点',h:1, e:function(){
			if(this.getSelect("text") !== "") {
				//this.pasteHTML('<a name="1" id="1" link="1">' + this.getSelect() + '</a>');
			}
			var _this=this;
			var seltext = _this.getSelect("text");
			var jTest=$('<div>请输入锚点ID：</div><div style="text-align:right;"><p><input type="text" id="s_name" /></p><input type="button" id="xheSave" value="确定" /></div>');
			var jSave=$('#xheSave',jTest);
			var jInput=$('#s_name',jTest);
			jSave.click(function(){
				_this.loadBookmark();
				if(seltext !== "") {
					if($.trim(jInput.val()) === "") {
						alert("请输入锚点ID");
						return false;
					}
					_this.pasteHTML('<a name="' + $.trim(jInput.val()) + '" id="' + $.trim(jInput.val()) + '" link="1" class="a_anchor">' + _this.getSelect('text') + '</a>');
				}
				_this.hidePanel();
				return false;	
			});
			_this.showDialog(jTest);
		}},
		linkToAnchor:{c:'linkToAnchor',t:'链接到以有锚点',h:1,e:function(){
			var _this=this;
			
			var jDiv=$('<div>选择锚点：</div><div style="text-align:right;"><select id="j_select"></select></div>');
			var jSelect=$('#j_select',jDiv);
			jSelect.append($("<option />").text("请选择锚点").val(""));
			
			var $doc = $("<p>" + _this.getSource() + "</p>");
			var $links = $("a", $doc);
			$links.each(function() {
				var $this = $(this);
				if($this.attr("link") === "1" && $.trim($this.text()) !== "") {
					var option = $("<option />").text($this.attr("name")).val($this.attr("name"));
					jSelect.append(option);
				}
			});
				
			jSelect.change(function(){
				if($.trim(_this.getSelect("text")) !== "") {
					_this.pasteHTML('<a href="#' + $(this).val() + '">' + _this.getSelect("text") + '</a>');
				}
				_this.hidePanel();
				return false;	
			});
			_this.showDialog(jDiv);
		}}
	};
	
	$textarea.xheditor({
		plugins:allPlugin,
		tools:'Cut,Copy,Paste,Pastetext,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,Align,List,Outdent,Indent,Table,Img',
		skin:'default',
		html5Upload:false,
		upMultiple:false,
		upImgUrl: "common/upload.action",
		upImgExt: "jpg,jpeg,gif,png"
	});
}
function successInfo( id ){
	$(id).html("");
}
function warnInfo( id, msg ){
	$(id).html(msg);
	$(id).css("color","red");
}
function initMsg( msgId, msg ){
	var initColor = "#999";
	$(msgId).html(msg);
	$(msgId).css("color",initColor);
}
function isdate(cal) {
	var reg = /^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/;
	return reg.test(cal);
}
function isempty(id) {
	var v = $.trim($("#" + id).val());
	if(v == null || v == "" || v == "<p>&nbsp;</p>") {
		return true;
	} else {
		return false;
	}
}

function setMenuCss(pid,mid){
	var menus = window.parent.menu;
	if(menus){//如果是在web父窗口中打开的
		var wdoc = $(window.parent.document);
		var pmenu = wdoc.find("a[menuId='"+pid+"']");
		if(pmenu){
			window.parent.objm.pmenuCss(pid);
			if(mid){
				window.parent.objm.cmenuCss(mid);
			}
		}
	}

}
function tzjhCss(){setMenuCss('16','1603');}


viewNews = function(id,type,stocktype){
		var url = "/news!donewsContent.action?type="+type+"&guid="+id+"&stocktype="+stocktype;	
		getNewsContent(url);
	}
	
//替换特殊html标记
function replaceHtml(str) {
	return str.replace(/\</g, '&lt;').replace(/\>/g, '&gt;').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
}
// 执行替换操作
function doReplaceHtml() {
	$(':input').each(function() {
		$(this).val(replaceHtml($(this).val()));
	});
}

/****
*分页页面间隔色区分
* 参数 str: 表格id
*/
function setColor(str){
	var sTable = document.getElementById(str);
	 for (var i=0; i < sTable.rows.length; i++)
	 {
	  var tmp = Math.floor((i-1) / 5)+1;
	  if(tmp%2!=0){
	   sTable.rows[i].style.backgroundColor="#FCF2F0";
	  }
	 }
}	
function ybllCss(){setMenuCss('16','1606');}

//取字符串长度
function strLen(str) {
    var a = 0;
    var i = 0;
	for (i=0;i<str.length;i++){
	   if (str.charCodeAt(i)>255){
	    a+=2;
	   }
	   else{ a++; }
	}
	return a; 
}
function comparedate(dstr, nstr) {
	dstr = dstr.replace(/-|:| /g, "");
	var nstr = nstr.replace(/-|:| /g, "");
	return nstr >= dstr;
}